<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
	<head>
		<link href="../../../js/thickbox.css" rel="stylesheet" type="text/css" />
		<script src="../../../js/jquery-1.5.min.js" type="text/javascript"></script>
		<script src="../../../js/jqtool.js" type="text/javascript"></script>
		<script src="../../../js/ui.js" type="text/javascript"></script>
		<script src="../../../js/thickbox-compressed.js"
			type="text/javascript"></script>
		<script src="../../../js/jqui/jquery-1.2.6.min.js"
			type="text/javascript"></script>
		<link href="../../../css/Public.css" type="text/css" rel="stylesheet" />
		<link href="../../../css/PublicEdit.css" type="text/css"
			rel="stylesheet" />
		<script language="javascript" src="../../../js/dateselect.js"></script>
		<title>新增房间</title>
		<style>
.gonggao {
	position: absolute;
	top: 80px;
	left: 200px;
	width: 430px;
	height: 300px;
	border: 1px solid #993300;
	background-color: #ffffff;
}

.gonggao h1 {
	line-height: 50px;
	font-size: 24px;
	font-family: "黑体";
	font-weight: bold;
	text-align: center;
}

.gonggao div {
	line-height: 30px;
	font-size: 18px;
	font-family: "黑体";
	text-align: center;
	color: #993300;
}

.gonggao div a,.gonggao div a:visited {
	color: #993300;
}
</style>

		<script type="text/javascript">
    function clsGG(srcpath)
    {
    	window.document.getElementById("viewimg").src= '${ctx}/showImage?imgfile='+srcpath;
    	//src;
    	//"E://Workspaces//MyEclipse9//ksappstore//WebRoot//upload//800X600//460.jpg";
        jQuery("#gonggao").toggle();        
    }
    function closediv()
    {
    document.all("gonggao").style.display="none";
    }
  
</script>
		<script type="text/javascript">
			function checkData(){
		        //房间ID不能重复			
		        var room_no=window.document.getElementById("room_no").value;	
    			if(room_no!=null && room_no!="")
		        {		
    		        if(!isInt(room_no)){
        		        alert("请输入数字编号");
        		        window.document.getElementById("room_no").focus();
		           	 	window.event.returnValue = false;
		            	return;
        		    }else{
		        	//限制 字符和数字、长度
			        	if(room_no.length>10)
			        	{
			        	 	alert("房间编号长度过长，最长10位！");
			        	 	window.document.getElementById("room_no").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	}	
			        
			        	 <c:forEach var="rlist" items="${KRoom}">	
			         	if(room_no=="${rlist.roomNo}")
			 			 {	
			     			 alert("该房间编号已经存在！");
			     			 window.event.returnValue = false;
				  			 return;
					  	}
	    			  </c:forEach>	
        		    }  
		        }else{
			  		alert("请输入房间编号");
			  		window.document.getElementById("room_no").focus();
	           	 	window.event.returnValue = false;
	            	return;
				}	

		        
					//验证数据   新用户名称
			        var room_startdate= window.document.getElementById("room_startdate").value;	
			        if(room_startdate==null ||room_startdate=="")
			        {	
			            alert("请选择开始日期！");
			            window.document.getElementById("room_startdate").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			        var room_enddate= window.document.getElementById("room_enddate").value;	
			        if(room_enddate==null ||room_enddate=="")
			        {	
			            alert("请选择结束日期！");
			            window.document.getElementById("room_enddate").focus();
			            window.event.returnValue = false;
			            return;
			        }	
			         if(Date.parse(room_startdate.replace("-","/")) > Date.parse(room_enddate.replace("-","/")))
			         {
						  alert("开始时间大于结束时间，请检查!");
						  window.document.getElementById("room_startdate").focus();
						   window.event.returnValue = false;
			           		return;
					 }										 
						  	        
			        
			        var room_starttime= window.document.getElementById("room_starttime").value;
			        if(room_starttime!=null &&room_starttime!="")
			        {				       							     
						if(!isInt(room_starttime))  
			        	{
			        		alert("开始时间点必须在0-24之间！");
			        	 	window.document.getElementById("room_starttime").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	} 	
			        	if (room_starttime < 0 || room_starttime > 24)
							{
							    alert("开始时间点必须在0-24之间！");	
							    window.document.getElementById("room_starttime").focus();
							    window.event.returnValue = false;									
								return;
							} 		
			        }
			        else
			        {	
			            alert("请输入开始时间！");
			            window.document.getElementById("room_starttime").focus();
			            window.event.returnValue = false;
			            return;
			        }	

			        var room_endtime= window.document.getElementById("room_endtime").value;
			        if(room_endtime!=null &&room_endtime!="")
			        {				       							     
						if(!isInt(room_endtime))  
			        	{
			        		alert("结束时间点必须在0-24之间！");
			        	 	window.document.getElementById("room_endtime").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	} 	
			        	if(room_endtime < 0 || room_endtime > 24)
							{
							    alert("结束时间点必须在0-24之间！");	
							    window.document.getElementById("room_endtime").focus();
							    window.event.returnValue = false;									
								return;
							} 		
			        }
			        else
			        {	
			            alert("请输入结束时间！");
			            window.document.getElementById("room_endtime").focus();
			            window.event.returnValue = false;
			            return;
			        }		


			        var room_amount=window.document.getElementById("room_amount").value;			        
	    			if(room_amount!=null && room_amount!="")
			        {		
			        	//限制 字符和数字、长度
			        	if(room_amount.length>5)
			        	{
			        	 	alert("房间数量长度过长，最长5位！");
			        	 	window.document.getElementById("room_amount").focus();
			           	 	window.event.returnValue = false;
			            	return;
			        	}	
			        }else{
				  		alert("请输入房间数量");
				  		window.document.getElementById("room_amount").focus();
		           	 	window.event.returnValue = false;
		            	return;
					}	
			        

					var chks=document.getElementsByTagName("input");
				     var len=chks.length;		   
				     for (i=0; i<len; i++) 
				     {
				        var cur=chks[i];
				        if(cur.type=="file")
				            {  				        
				              
				            	var fv=cur.value;				           
				            	if(fv==null||fv=='')
				            	{
					            	//upimg="false";
					            	//break;		
					            	alert("请选择图片上传！");	
					       			window.document.getElementById(cur.id).focus();
								    window.event.returnValue = false;
								    return;				            	
				            	}
				            	else
				            	{
				            		var extname = fv.substring(fv.lastIndexOf(".")+1,fv.length);
									   extname = extname.toLowerCase();//处理了大小写
									    if(extname!= "bmp"&&extname!= "jpg"&&extname!= "gif"&&extname!="png")
									    {
									       alert("只能上传bmp,jpg,gif,png格式的图片！");
									       window.event.returnValue = false;
								   			 return;	
									    }						            		
				            	}
					        }       
				    }	
			}	
			//定义正则表达式校验
			function isInt(str)
			{
				//var reg = /^(-|\+)?\d+$/ ;
				if(str==0)return true;
				var reg = /^[0-9]\d*$/;	
				return reg.test(str);			
			}		
</script>
	</head>
	<body>
		<form action="/admin/product/saveroom" name="bbform" id="bbform"
			method="post" enctype="multipart/form-data"
			onsubmit="javascript:checkData()">
			<div id="gonggao" class="gonggao" style="display: none">
				<img name="viewimg" id="viewimg" style="width: 400; height: 300" />
				<a href="javascript:closediv();">关闭</a>
			</div>
			<div class="l_f_top">
				<div class="l_f_top_left_div">
					<img alt="" src="../../../images/tb.gif" width="16" height="16" />
				</div>
				<div class="l_f_top_right_div">
					新增房间
				</div>
			</div>
			<div class="l_f_body">
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						房间类型:
					</div>
					<div class="l_f_body_div5">
						<select style="width: 90px" name="room_type" id="room_type">
							<option value="1">
								迷你房
							</option>
							<option value="2">
								豪华房
							</option>
							<option value="3">
								K歌房
							</option>
						</select>
					</div>
				</div>
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						房间编号:
					</div>
					<div class="l_f_body_div5">
						<input type="text" name="room_no" id="room_no"
							style="width: 150px" />
					</div>
				</div>
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						开始日期:
					</div>
					<div class="l_f_body_div5">
						<input type="text" onclick="show_calendar(this)"
							name="room_startdate" id="room_startdate"
							style="width: 150px" />
					</div>
				</div>
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						结束日期:
					</div>
					<div class="l_f_body_div5">
						<input type="text" onclick="show_calendar(this)"
							name="room_enddate" id="room_enddate" style="width: 150px" />
					</div>
				</div>
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						开始时间:
					</div>
					<div class="l_f_body_div5">
						<input type="text" name="room_starttime" id="room_starttime"
							style="width: 120px" maxlength="2" value="0" />
						点
					</div>
				</div>
				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						结束时间:
					</div>
					<div class="l_f_body_div5">
						<input type="text" name="room_endtime" id="room_endtime"
							style="width: 120px" maxlength="2" value="24" />
						点
					</div>
				</div>

				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						房间数量:
					</div>
					<div class="l_f_body_div5">
						<input type="text" name="room_amount" id="room_amount"
							value="0" style="width: 120px" maxlength="2" />
					</div>
				</div>

				<div class="l_f_body_row">
					<div class="l_f_body_div1">
						上传图片:
					</div>
					<div class="l_f_body_div5">
						<input type="file" name="file" style="width: 300px"
							id="file" /> <input type="button" class="button2_60"  onclick="clsGG(${param.file});" value="查看"/>
					</div>

					<div class="l_f_body_row">
						<div class="l_f_body_div1">
							状态:
						</div>
						<div class="l_f_body_div5">
							<select name="room_state" id="room_state"
								style="width: 120px">
								<option value="0">
									关闭
								</option>
								<option value="1" selected>
									开放
								</option>
								<option value="2" selected>
									未审核
								</option>
							</select>
						</div>
					</div>
					<div class="center l_f_body_foot">
						<input type="submit" id="button" name="button" class="button2_60" value="提交" />
						<input type="button" class="button2_60"
							onclick="javascript:history.go(-1);" value=" 返回" />
		                      <input type="button" class="button2_60"  onclick="clsGG('E://1.png');" value="test"/>
		                      <input type="button" class="button2_60"  onclick="clsGG('F://阳朔旅游//DSC05564.JPG');" value="test"/>  
					</div>
				</div>
			</div>
		</form>
	</body>
</html>